package com.yiwei.hdb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.hdb.R;
import com.yiwei.hdb.adapter.base.ItemAdapter;
import com.yiwei.hdb.model.HelpModel;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class V4HelpAdapter extends ItemAdapter<HelpModel.DataList, V4HelpAdapter.DefaultHolder> {


    private Context context;

    public V4HelpAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_help_title_v4, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        HelpModel.DataList item = getItem(position);
        holder.txtTitle.setText(item.getTitle());
        V4HelpItemAdapter adapter = new V4HelpItemAdapter(context);
        holder.list.setAdapter(adapter);
        adapter.update(item.getList());
    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_title)
        TextView txtTitle;
        @BindView(R.id.list)
        RecyclerView list;

        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
